<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "/jeecms_sys/head.html"/>
<script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/swfupload.queue.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/fileprogress.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/handlers.js" type="text/javascript"></script>
<link href="${base}/thirdparty/swfupload/process.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
$(function() {
	$("#jvForm").validate();
	//选择框联动,根据品牌获取车系 ,根据车系获取车型
		$("#carBrandId").change(function(){
			$.post('getCarSeries.do',
					{bid:$(this).val()},
					function(data,textStatus){
						$("#carSeriesId").html("");
						var json = eval(data);
						$.each(json,function(i,item){
							$("#carSeriesId").append("<option value="+item.sid+">"+item.sname+"</option>");
						});
					});
			
		})
});
var swfu;
window.onload=function() {
var uploadPicsUrl = "../common/o_swfPicsUpload.do";
	var uploadAttachsUrl = "../common/o_swfAttachsUpload.do";
	//在firefox、chrome下，上传不能保留登录信息，所以必须加上jsessionid。
	var jsessionid = $.cookie("JSESSIONID");
	if(jsessionid) {
		uploadPicsUrl += ";jsessionid="+jsessionid;
		uploadAttachsUrl += ";jsessionid="+jsessionid;
	}

	swfu=new SWFUpload({
		upload_url : uploadPicsUrl,
		flash_url : "${base}/thirdparty/swfupload/swfupload.swf",
		file_size_limit : "20 MB",
		file_types : "*.jpg;*.gif;*.png;*.bmp",
		file_types_description : "<@s.m 'content.picture'/>",
		file_queue_limit : 0,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},
		debug: false,
		
		button_image_url : "${base}/thirdparty/swfupload/button_notext.png",
		button_placeholder_id : "spanButtonPlaceHolder",
		button_text: "<span class='btnText'><@s.m "content.pictures.upload"/></span>",
		button_width: 84,
		button_height: 24,
		button_text_top_padding: 2,
		button_text_left_padding: 20,
		button_text_style: '.btnText{color:#666666;}',
		
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadPicsStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadPicsSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete
	});
};

function uploadPicsStart(file) {
	addPicLine();
}
var picIndex = 3;
var picTpl = $.format($("#picTable").val());
function addPicLine() {
	$('#picBefore').before(picTpl(picIndex++));
}
////

function uploadAttachStart(file) {
	addAttachLine();
}
function uploadAttachSuccess(file,data) {
	var index = attachIndex - 1;
	var jsonData=eval("("+data+")");//转换为json对象 
	var attachUrl=jsonData.attachUrl;
	var attachName=jsonData.attachName;
	$("#attachmentPaths"+index).val(attachUrl);
	$("#attachmentNames"+index).val(attachName);
}
function uploadPicsSuccess(file,imgUrl) {
	var index = picIndex - 1;
	$("#preImg"+index).attr("src",""+imgUrl);
	var imgSrc = parent.document.getElementById("preImg"+index);
	if(!$(imgSrc).attr("noResize")) {
		$(imgSrc).css("width","auto");
		$(imgSrc).css("height","auto");
	}
	$("#uploadImgPath"+index).val(imgUrl);
}
</script>
</head>
<body>
<div class="box-positon"> 
	<div class="rpos"><@s.m "global.position"/>: <@s.m "carType.function"/> - <@s.m "global.edit"/></div>
	<!-- 
	<form class="ropt">
		<input type="button" value="<@s.m "global.backToList"/>" onclick="history.back();" class="return-button"/>
	</form> -->
	<div class="clear"></div>
</div>
<div class="body-box">
<#include "/common/image_upload.html"/>
<#include "attachment_upload.html"/>
<#assign usernameExist><@s.m "error.usernameExist"/></#assign>
<@p.form id="jvForm" action="o_update.do" labelWidth="12">

<@p.text width="50" colspan="1" label="车型名称" name="typeName" value=carType.typeName class="required" required="true" maxlength="30"/>
<@p.select colspan="1" label="shopInfo.shopName" name="shopId" value=carType.shop.id list=listShop listKey="id" listValue="shopName" class="required" required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="年款" name="year" class="Wdate" value=carType.year required="true" maxlength="30" onclick="WdatePicker({dateFmt:'yyyy'})"/>
<@p.select colspan="1" label="品牌" id="carBrandId" name="carBrandId" value=carType.carBrand.id list=listCarBrand listKey="id" listValue="brandName" class="required" required="true"/><@p.tr/>


<@p.text width="50" colspan="1" label="指导价(元)" name="priceGuide" value=carType.priceGuide  class="required number" required="true" maxlength="30"/>
<@p.select colspan="1" label="车系" id="carSeriesId" name="carSeriesId" value=carType.carSeries.id list=listCarSeries listKey="id" listValue="shortName" class="required" required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="经销商报价(元)" name="priceSale"  value=carType.priceSale class="required number" required="true" maxlength="30"/>
<@p.text width="50" colspan="1" label="排量" name="disp" value=carType.disp class="required" required="true" maxlength="30"/><@p.tr/>

<@p.text width="50" colspan="1" label="档位个数" name="gearNum" value=carType.gearNum  class="required digits" required="true" maxlength="30"/>
<@p.text width="50" colspan="1" label="变速箱" name="gearbox" value=carType.gearbox class="required" required="true" maxlength="30"/><@p.tr/>

<@p.text width="50" colspan="1" label="排序号" name="orderNum" value=carType.orderNum maxlength="4" class="required digits"  required="true" help="排序号越大越靠前"/>
<@p.textarea label="车型亮点"  name="content" cols="30" rows="2" value=carType.content maxlength="500" colspan="1" class="required" required="true" width="50"/><@p.tr/>


<!-- 批量上传 开始 -->
<@p.td label="批量上传" colspan="2" noHeight="true">
<div>
<span id="spanButtonPlaceHolder"></span>
<span style="display: none;"><input class="cancel" id="btnCancel" type="button" value="<@s.m "global.cancel"/>" onclick="swfu.cancelQueue();" disabled="disabled" /></span>
<div id="fsUploadProgress" style="display: none;"></div>
</div>
<#list carType.carImgs as p>
<table id="picTable${p_index+3}" border="0" style="float:left;">
<tr>
	<td>
		<div>
            <input type="text" id="uploadImgPath${p_index+3}" name="imgUrls" value="${p.imgUrl}" style="width:170px"/> <a href="javascript:void(0);" onclick="$('#picTable${p_index+3}').remove();" class="pn-opt"><@s.m "content.picturesDel"/></a></div>
		<div>
		<span id="ufc${p_index+3}" style="position:relative">
		<input type='text' id='uploadFileText${p_index+3}' size="10"/>
		<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
		<input onchange="$('#uploadFileText${p_index+3}').val(this.value)" size="10" type="file" id="uploadFile${p_index+3}" class="file-button"/>
		</span>
		<input type="button" value="<@s.m "content.fileUpload"/>" onclick="upload(${p_index+3});" class="upload-button"/>
		</div>
	</td>
	<td><img id="preImg${p_index+3}" src="${p.imgUrl}" alt="<@s.m "imageupload.preview"/>" noResize="true" style="width:110px;height:110px;background-color:#ccc;border:1px solid #333"/></td>
</tr>
</table>
<input type="hidden" name="oldpicPaths" value="${p.imgUrl!}"/>
</#list>
<div id="picBefore" style="clear:both"></div>
<textarea id="picTable" style="display:none;">
<table id="picTable{0}" border="0" style="float:left;">
<tr>
	<td>
		<div><input type="text" id="uploadImgPath{0}" name="imgUrls" style="width:160px"/> <a href="javascript:void(0);" onclick="$('#picTable{0}').remove();" class="pn-opt"><@s.m "content.picturesDel"/></a></div>
		<div>
		<span id="ufc{0}" style="position:relative">
		<input type='text' id='uploadFileText{0}' size="10"/>
		<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
		<input onchange="$('#uploadFileText{0}').val(this.value)" size="10" type="file" id="uploadFile{0}" class="file-button"/>
		</span>
		<input type="button" value="<@s.m "content.fileUpload"/>" onclick="upload({0});" class="upload-button"/>
		</div>
		<div>&lt;textarea style="width:200px;height:60px;" name="imgNames" maxlength="255"&gt;&lt;/textarea&gt;</div>
	</td>
	<td><img id="preImg{0}" alt="<@s.m "imageupload.preview"/>" noResize="true" style="width:110px;height:110px;background-color:#ccc;border:1px solid #333"/></td>
</tr>
</table>
</textarea>
<script type="text/javascript">
var picIndex = ${carType.carImgs?size} + 3;
var picTpl = $.format($("#picTable").val());
function addPicLine() {
	$('#picBefore').before(picTpl(picIndex++));
}
</script>
</@p.td>
<!-- 批量上传结束 -->
<@p.tr/>
<@p.hidden name="id" value=carType.id/>
<@p.td colspan="2"><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
</@p.form>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>